<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests"> 
		<title>server2</title>
	</head>
	<body>
		<h1>这是二号服务器，端口3001</h1>

		<button id="fetchBtn3001">向端口3001发起fetch请求获取cookie</button>

		<button id="fetchBtn3000">向端口3000发起fetch请求获取cookie</button>

        <a href="https://www.server1.com:3000">跳转到服务器1</a>
	</body>
	<script type="text/javascript">
		(() => {
			// 获取按钮
			const fetchBtn = document.getElementById('fetchBtn3001');

			// 点击按钮发起请求
			fetchBtn.addEventListener('click', () => {
				fetch('https://localhost:3001/set-cookie', {
					method: 'GET',
					credentials: 'include',
                    cache:"no-cache"
				})
					.then((res) => res.text())
					.then((res) => {
						console.log(res);
					});
			});
		})();

        (() => {
			// 获取按钮
			const fetchBtn = document.getElementById('fetchBtn3000');

			// 点击按钮发起请求
			fetchBtn.addEventListener('click', () => {
				fetch('https://www.server1.com:3000/set-cookie', {
					method: 'GET',
					credentials: 'include',
                    cache:"no-cache",
                    headers: {
                        'haha':'xiaoxiwola'
                    }
				})
					.then((res) => res.text())
					.then((res) => {
						console.log(res);
					});
			});
		})();
	</script>
</html>
